home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / TC Prog Guide.cpt / picture ƒ / pict.c < prev    next >
C/C++ Source or Header  |  1991-02-26  |  2KB  |  72 lines

  1. /*
  2. *    FILE:        pict.c
  3. *    AUTHOR:        R. Gonzalez
  4. *    CREATED:    November 7, 1990
  5. *
  6. *    generic pict application methods.  You should define a single
  7. *    object of a class descending from Generic_Pict in your application,
  8. *    and your main() function should simply send this object init(),
  9. *    run(), and destroy() messages.
  10. */
  11.  
  12. # include    "pict.h"
  13. # include    "error.h"
  14.  
  15. Error    *gerror;        /* global to report errors */
  16.  
  17. /******************************************************************
  18. *    initialize - be sure to call inherited method first when
  19. *    overriding
  20. ******************************************************************/
  21. boolean    Generic_Pict::init(void)
  22. {
  23.     double    aspect;
  24.  
  25.     gerror = new(Error);
  26.     gerror->init();
  27.  
  28. # ifdef    THINK_C
  29.     screen = new(Mac_Screen);
  30. # else
  31.     screen = new(PC_Screen);
  32. # endif
  33.  
  34.     screen->init();
  35. /*    screen->init() should do this, but just to be sure: */
  36.     aspect = screen->get_device_aspect_ratio();
  37.     screen->set_normalized_frame(0.,0.,2.,2./aspect); 
  38.  
  39.     backdrop = new(Backdrop_Projector);
  40.     backdrop->init();
  41.     backdrop->set_screen(screen);
  42.     
  43.     return TRUE;
  44. }
  45.  
  46. /******************************************************************
  47. *    run - override freely
  48. ******************************************************************/
  49. void    Generic_Pict::run(void)
  50. {
  51.     screen->wait();
  52. }
  53.  
  54. /******************************************************************
  55. *    destroy - be sure to call inherited method after overriding
  56. ******************************************************************/
  57. boolean    Generic_Pict::destroy(void)
  58. {
  59.     backdrop->destroy();
  60.     delete(backdrop);
  61.     
  62.     screen->destroy();
  63.     delete(screen);
  64.     
  65.     gerror->destroy();
  66.     delete(gerror);
  67.     
  68.     return TRUE;
  69. }
  70.  
  71.     
  72.